package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.data.TBSuper_BaseTimeAndOrderValue;

/**
 *
 * (产品分类属性)TB_ProductCategoryProperty
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_ProductCategoryProperty#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_productCategoryProperty")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("产品分类属性")
@com.lianjing.sh.processing.info.annotation.InfoComment("产品分类属性")
public class TB_ProductCategoryProperty
 extends TBSuper_BaseTimeAndOrderValue
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty>,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		public bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty getId();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_ProductCategoryProperty properties(MustProperties properties) {
		this.setId(properties.getId());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_ProductCategoryProperty(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_ProductCategoryProperty properties(OptionalSingleProperties properties) {
		return this;
	}
	
	
	
	public TB_ProductCategoryProperty(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		public bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty getId();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_ProductCategoryProperty properties(CurrentMustProperties properties) {
		this.setId(properties.getId());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_ProductCategoryProperty properties(CurrentOptionalSingleProperties properties) {
		return this;
	}
	
	public TB_ProductCategoryProperty(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseTimeAndOrderValue bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_ProductCategoryProperty(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseTimeAndOrderValue bean
	) {
		update(bean);
	}
	
	public TB_ProductCategoryProperty update(com.lianjing.sh.model.uml.model.data.TBSuper_BaseTimeAndOrderValue bean){
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_ProductCategoryProperty.this);
			if(isOverride_getOrderValue){
				TB_ProductCategoryProperty.this.setOrderValue(orderValue);
			}
	
			bairui.international.model.domain.jpa.TB_ProductProperty productProperty = getProductProperty(TB_ProductCategoryProperty.this);
			if(isOverride_getProductProperty){
				TB_ProductCategoryProperty.this.setProductProperty(productProperty);
			}
	
			bairui.international.model.domain.jpa.TB_ProductCategory productCategory = getProductCategory(TB_ProductCategoryProperty.this);
			if(isOverride_getProductCategory){
				TB_ProductCategoryProperty.this.setProductCategory(productCategory);
			}
	
			java.util.List<bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem> productCategoryPropertyItems = getProductCategoryPropertyItems(TB_ProductCategoryProperty.this);
			if(isOverride_getProductCategoryPropertyItems){
				TB_ProductCategoryProperty.this.setProductCategoryPropertyItems(productCategoryPropertyItems);
			}
		}
	
		public TB_ProductCategoryProperty up(){
			return TB_ProductCategoryProperty.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_ProductCategoryProperty it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 产品属性 */
		private boolean isOverride_getProductProperty = true;
		public bairui.international.model.domain.jpa.TB_ProductProperty getProductProperty(TB_ProductCategoryProperty it) throws Exception { 
			isOverride_getProductProperty = false; 
			return null;
		}
		/** 产品分类 */
		private boolean isOverride_getProductCategory = true;
		public bairui.international.model.domain.jpa.TB_ProductCategory getProductCategory(TB_ProductCategoryProperty it) throws Exception { 
			isOverride_getProductCategory = false; 
			return null;
		}
		/** 产品分类属性项 */
		private boolean isOverride_getProductCategoryPropertyItems = true;
		public java.util.List<bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem> getProductCategoryPropertyItems(TB_ProductCategoryProperty it) throws Exception { 
			isOverride_getProductCategoryPropertyItems = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_ProductCategoryProperty() {
	}
	
	public TB_ProductCategoryProperty(
		@lombok.NonNull bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty id
	) {
		this.setId(id);
	}
	
	public TB_ProductCategoryProperty(
		@lombok.NonNull TB_ProductCategoryProperty bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setProductProperty(bean.getProductProperty());
		this.setProductCategory(bean.getProductCategory());
		this.setProductCategoryPropertyItems(bean.getProductCategoryPropertyItems());
		this.setCreator(bean.getCreator());
		this.setLastModifier(bean.getLastModifier());
	}
	
	

	/**
	 * 联合主键
	 */
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.EmbeddedId
	@org.hibernate.annotations.Target(bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty.class)
	private bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty id;
	
	@com.fasterxml.jackson.databind.annotation.JsonSerialize(using=bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty.CompositePKSerializer.class)
	public bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty getId() {
		return this.id;
	}
	public void setId(bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty id) {
		this.id = id;
		if(null != this.id){
			this.setProductProperty(this.id.getProductProperty());
			this.setProductCategory(this.id.getProductCategory());
		}
	}
	public void setId_only(bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty id) {
		this.id = id;
	}
	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("产品属性")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品属性")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	@javax.persistence.JoinColumn(insertable=false, updatable=false)
	private bairui.international.model.domain.jpa.TB_ProductProperty productProperty;

	@com.lianjing.sh.model.common.annotation.Comment("产品分类")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品分类")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	@javax.persistence.JoinColumn(insertable=false, updatable=false)
	private bairui.international.model.domain.jpa.TB_ProductCategory productCategory;

	@com.lianjing.sh.model.common.annotation.Comment("产品分类属性项")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品分类属性项")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.OneToMany(mappedBy="productCategoryProperty")
	private java.util.List<bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem> productCategoryPropertyItems;

	@com.lianjing.sh.model.common.annotation.Comment("创建者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("创建者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="creator_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin creator;

	@com.lianjing.sh.model.common.annotation.Comment("最后修改者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("最后修改者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="lastModifier_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin lastModifier;

	/** get[产品属性] */
	public bairui.international.model.domain.jpa.TB_ProductProperty getProductProperty() {
		return this.productProperty;
	}

	/** get[产品分类] */
	public bairui.international.model.domain.jpa.TB_ProductCategory getProductCategory() {
		return this.productCategory;
	}

	/** get[产品分类属性项] */
	public java.util.List<bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem> getProductCategoryPropertyItems() {
		return this.productCategoryPropertyItems;
	}

	/** get[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin getCreator() {
		return this.creator;
	}

	/** get[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin getLastModifier() {
		return this.lastModifier;
	}

	/** set[产品属性] */
	public void setProductProperty(bairui.international.model.domain.jpa.TB_ProductProperty productProperty) {
		this.productProperty = productProperty;
	}

	/** set[产品分类] */
	public void setProductCategory(bairui.international.model.domain.jpa.TB_ProductCategory productCategory) {
		this.productCategory = productCategory;
	}

	/** set[产品分类属性项] */
	public void setProductCategoryPropertyItems(java.util.List<bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem> productCategoryPropertyItems) {
		this.productCategoryPropertyItems = productCategoryPropertyItems;
	}

	/** set[创建者] */
	public void setCreator(bairui.international.model.domain.jpa.TB_Admin creator) {
		this.creator = creator;
	}

	/** set[最后修改者] */
	public void setLastModifier(bairui.international.model.domain.jpa.TB_Admin lastModifier) {
		this.lastModifier = lastModifier;
	}

	public void assignProductProperty(bairui.international.model.domain.jpa.TB_ProductProperty productProperty) {
		if(null != productProperty){
			productProperty.addProductCategoryProperties(this);
		}
		this.setProductProperty(productProperty);
	}
	

	public void assignProductCategory(bairui.international.model.domain.jpa.TB_ProductCategory productCategory) {
		if(null != productCategory){
			productCategory.addProductCategoryProperties(this);
		}
		this.setProductCategory(productCategory);
	}
	




	/** add[ProductCategoryPropertyItems] */
	public TB_ProductCategoryProperty addProductCategoryPropertyItems(bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem ... productCategoryPropertyItems){
		if(this.productCategoryPropertyItems == null){
			this.productCategoryPropertyItems = new java.util.ArrayList<>();
		}
		for(bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem bean : productCategoryPropertyItems){
			bean.setProductCategoryProperty(this);
			this.productCategoryPropertyItems.add(bean);
		}
		return this;
	}
	
	/** remove[ProductCategoryPropertyItems] */
	public TB_ProductCategoryProperty removeProductCategoryPropertyItems(bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem ... productCategoryPropertyItems){
		if(this.productCategoryPropertyItems == null){
			return this;
		}
		for(bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem bean : productCategoryPropertyItems){
			bean.setProductCategoryProperty(null);
			this.productCategoryPropertyItems.remove(bean);
		}
		return this;
	}
	
	/**
	 * contains[ProductCategoryPropertyItems]
	 *
	 * 全部输入都包含：返回 true
	 * 输入中有至少有一个不包含：返回 false
	 */
	public boolean containsProductCategoryPropertyItems(bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem ... productCategoryPropertyItems){
		if(this.productCategoryPropertyItems == null || productCategoryPropertyItems==null || productCategoryPropertyItems.length<=0){
			return false;
		}
		return this.productCategoryPropertyItems.containsAll(java.util.Arrays.asList(productCategoryPropertyItems));
	}
	

	/** take[产品属性] */
	public bairui.international.model.domain.jpa.TB_ProductProperty takeProductProperty(){
		if(null == this.productProperty){
			this.productProperty = new bairui.international.model.domain.jpa.TB_ProductProperty();
		}
		return this.productProperty;
	}
	
	/** take[产品分类] */
	public bairui.international.model.domain.jpa.TB_ProductCategory takeProductCategory(){
		if(null == this.productCategory){
			this.productCategory = new bairui.international.model.domain.jpa.TB_ProductCategory();
		}
		return this.productCategory;
	}
	
	/** take[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin takeCreator(){
		if(null == this.creator){
			this.creator = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.creator;
	}
	
	/** take[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin takeLastModifier(){
		if(null == this.lastModifier){
			this.lastModifier = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.lastModifier;
	}
	
	/** must[产品属性] */
	public bairui.international.model.domain.jpa.TB_ProductProperty mustProductProperty() {
		return this.productProperty;
	}
	
	/** must[产品分类] */
	public bairui.international.model.domain.jpa.TB_ProductCategory mustProductCategory() {
		return this.productCategory;
	}
	
	/** must[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin mustCreator() {
		return this.creator;
	}
	
	/** must[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin mustLastModifier() {
		return this.lastModifier;
	}
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_ProductCategoryProperty other = (TB_ProductCategoryProperty) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
		this.setCreator((bairui.international.model.domain.jpa.TB_Admin)user);
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setModifyTime(new java.util.Date());
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}



}
